#include "Bullet.h"
#include "Direction.h"
#include "texturemanager.h"

bool Bullet::first = true;
Texture* Bullet::m_animate0 = nullptr;

Bullet::Bullet(int x, int y, int direction):Sprite() {
	m_x = x;
	m_y = y;
	m_direction = direction?direction:EAST;
	if (first) {
		m_animate0 = TextureManager::Instance()->GetTexture("asset/bullet.png");
		first = false;
	}
	SetTexture(m_animate0);
	SetScale(0.1);
}
void Bullet::Move() {
	if (m_direction & NORTH) {
		m_y -= m_speed;
	}
	if (m_direction & WEST) {
		m_x -= m_speed;
	}
	if (m_direction & SOUTH) {
		m_y += m_speed;
	}
	if (m_direction & EAST) {
		m_x += m_speed;
	}
	if (m_direction & WEST && m_direction & EAST) {
		m_x += m_speed;
	}
	if (m_direction & NORTH && m_direction & SOUTH) {
		m_y += m_speed;
	}
}